package com.mall.huohuo.service.address.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * @author zyconding
 * @version AuthParam.java, v 0.1 2020-08-07 16:23 zyconding
 */
@Setter
@Getter
@Accessors(chain = true)
@RequiredArgsConstructor
@Valid
public class MemberAddress implements Comparable<MemberAddress> {

    @JsonProperty(ADDRESS_ID)
    private Long id;

    @NotBlank(message = "接收人名字不能为空。")
    private String receiveName;

    @NotBlank(message = "接收人手机号不能为空。")
    private String receiveMobile;

    private String province;
    private String city;
    private String area;
    private String address;

    @NotNull(message = "是否默认值不能为空")
    private Boolean isDefault;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    private static final String ADDRESS_ID ="addressId";

    private Boolean isDeleted;

    @Override
    public int compareTo(MemberAddress memberAddress) {
        return memberAddress.isDefault?1:0;
    }
}
